﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using mscook.core;
using mscook.core.domain;
using mscook.core.services;

namespace mscook.test.BonusStrategyTest
{
    class BonusStrategyMock : BaseBonusStrategyMock, IActionBonusSettingService, ILoginUserService, IResourceBonusSettingService
    {
        private LoginUser loginUser;
        private IList<ActionBonusSetting> actionBonusSettings;
        private IList<ResourceBonusSetting> resourceBonusSettings;
        public BonusStrategyMock(LoginUser loginUser, IList<ActionBonusSetting> actionBonusSettings, IList<ResourceBonusSetting> resourceBonusSettings)
        {
            this.loginUser = loginUser;
            this.actionBonusSettings = actionBonusSettings;
            this.resourceBonusSettings = resourceBonusSettings;
        }

        #region IActionBonusSettingService 成员

        IList<ActionBonusSetting> IActionBonusSettingService.Select()
        {
            return actionBonusSettings;
        }



        void IActionBonusSettingService.SaveOrUpdate(ActionBonusSetting actionBonusSetting)
        {
            var item = actionBonusSettings.Where(x => x.Id == actionBonusSetting.Id).FirstOrDefault();
            actionBonusSettings.Remove(item);
            actionBonusSettings.Insert(0, actionBonusSetting);
        }



        void IActionBonusSettingService.Delete(string id)
        {
            var item = actionBonusSettings.Where(x => x.Id == id).FirstOrDefault();
            actionBonusSettings.Remove(item);
        }

        #endregion

        #region ILoginUserService 成员

        public void SaveOrUpdate(core.domain.LoginUser loginUser)
        {
            this.loginUser = loginUser;
        }
        public bool ValidateLoginUserByPsd(string exitLoginName, string exitPsd)
        {
            return true;
        }
        LoginUser ILoginUserService.Get(string id)
        {
            return loginUser;
        }
        LoginUser ILoginUserService.SelectLoginUserByLoginName(string loginName)
        {
            return loginUser;
        }

        IList<LoginUser> ILoginUserService.SelectLimitLoginUserByType(bool isAnonymous, int start, int limit, out long total, System.Linq.Expressions.Expression<Func<LoginUser, bool>> expression)
        {
            total = 0;
            return null;
        }
        IList<LoginUser> ILoginUserService.SelectLimitSystemUser(bool isVip, int start, int limit, out long total, System.Linq.Expressions.Expression<Func<LoginUser, bool>> expression)
        {
            total = 0;
            return null;
        }

        LoginUser UserLogOnSelectByLoginNameOrEmail(string InputValue)
        {
            return loginUser;
        }

        public bool IsNullByLoginNameOrEmail(string value, string email)
        {
            return true;
        }

        #endregion

        #region IResourceBonusSettingService 成员

        IList<ResourceBonusSetting> IResourceBonusSettingService.SelectAll()
        {
            return resourceBonusSettings;
        }

        void IResourceBonusSettingService.SaveOrUpdate(ResourceBonusSetting resourceBonusSetting)
        {
            var item = resourceBonusSettings.Where(x => x.Id == resourceBonusSetting.Id).FirstOrDefault();
            resourceBonusSettings.Remove(item);
            resourceBonusSettings.Insert(0, resourceBonusSetting);
        }

        void IResourceBonusSettingService.Delete(string id)
        {
            var item = resourceBonusSettings.Where(x => x.Id == id).FirstOrDefault();
            resourceBonusSettings.Remove(item);
        }

        IList<ResourceBonusSetting> IResourceBonusSettingService.SelectByAriticKey(string year, string month)
        {
            return null;
        }

        ResourceBonusSetting IResourceBonusSettingService.SelectByResourceId(string resourceId)
        {
            return null;
        }

        IList<ResourceBonusSetting> IResourceBonusSettingService.SelectByAriticKeyAndType(string year, string month, PurchasedCategory purchasedCategory)
        {
            return null;
        }

        #endregion

    }
}
